const multer  = require('multer')
// const upload = multer({ dest: 'uploads/' })
const storage = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, 'public/uploads/')
  },
  filename: function (req, file, cb) {
    console.log(file)
    let fileArr = file.originalname.split('.')
    let extName = fileArr[fileArr.length-1]
    cb(null, file.fieldname + '-' + Date.now()+'.'+extName)
  }
})
 
const upload = multer({ storage: storage })

module.exports = upload